Stay organized with collections
Save and categorize content based on your preferences.
This rules triggers when PageSpeed Insights detects that the size of one of your resources could
be reduced through minification.
Overview
Minification refers to the process of removing unnecessary or redundant data without affecting how
the resource is processed by the browser - e.g. code comments and formatting, removing unused code,
using shorter variable and function names, and so on.
To minify JavaScript, try UglifyJS. The Closure Compiler
is also very effective. You can create a build process that uses these tools to minify and rename the
development files and save them to a production directory.
Alternatively, the PageSpeed Module,
integrates with an Apache or Nginx web server to automatically optimize your site, including resource minification.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-03 UTC."],[[["\u003cp\u003eThis documentation is outdated and refers to a deprecated version of PageSpeed Insights API (v4) which will be shut down.\u003c/p\u003e\n"],["\u003cp\u003eMinification is the process of removing unnecessary data from web resources (HTML, CSS, JavaScript) without impacting functionality, improving page load speed.\u003c/p\u003e\n"],["\u003cp\u003eYou can use tools like HTMLMinifier, CSSNano, csso, UglifyJS, and Closure Compiler to minify your resources.\u003c/p\u003e\n"],["\u003cp\u003eThe PageSpeed Module for Apache or Nginx servers can automatically optimize your site, including minification.\u003c/p\u003e\n"]]],["Minification reduces resource size by removing unnecessary data without affecting browser processing. Key actions include minifying HTML, CSS, and JavaScript. Use tools like HTMLMinifier for HTML, CSSNano or csso for CSS, and UglifyJS or Closure Compiler for JavaScript. A build process can automate minification, or the PageSpeed Module can optimize sites on Apache/Nginx servers. The content refers to PageSpeed Insights for identifying areas for minification.\n"],null,["# Minify Resources (HTML, CSS, and JavaScript)\n\n| **Deprecated** . This page was written for version 4 of the PageSpeed Insights API, which is deprecated and will be shut down in May 2019. [Version 5](/speed/docs/insights/v5/get-started) is the latest and provides both real-world data from the Chrome User Experience Report and lab data from Lighthouse.\n\nThis rules triggers when PageSpeed Insights detects that the size of one of your resources could\nbe reduced through minification.\n\n### Overview\n\nMinification refers to the process of removing unnecessary or redundant data without affecting how\nthe resource is processed by the browser - e.g. code comments and formatting, removing unused code,\nusing shorter variable and function names, and so on.\n\nSee [preprocessing \\& context-specific optimizations](/web/fundamentals/performance/optimizing-content-efficiency/optimize-encoding-and-transfer#minification-preprocessing--context-specific-optimizations) to learn more.\n\n### Recommendations\n\nYou should minify your HTML, CSS, and JavaScript resources:\n\n- **To minify HTML,** try [HTMLMinifier](https://github.com/kangax/html-minifier)\n- **To minify CSS,** try [CSSNano](https://github.com/ben-eb/cssnano) and [csso](https://github.com/css/csso).\n- **To minify JavaScript,** try [UglifyJS](https://github.com/mishoo/UglifyJS2). The [Closure Compiler](/closure/compiler) is also [very effective](https://github.com/samccone/The-cost-of-transpiling-es2015-in-2016#summary-of-findings). You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.\n\nAlternatively, the [PageSpeed Module](/speed/pagespeed/module),\nintegrates with an Apache or Nginx web server to automatically optimize your site, including resource minification.\n\nFeedback\n--------\n\nWas this page helpful? \nYes Great! Thank you for the feedback. If you have a specific, answerable question about using PageSpeed Insights, ask the question in English on [Stack\n| Overflow](https://stackoverflow.com/questions/tagged/pagespeed-insights). For general questions, feedback, and discussion, start a thread in the [mailing list](https://groups.google.com/forum/#!forum/pagespeed-insights-discuss).\nNo Sorry to hear that. If you have a specific, answerable question about using PageSpeed Insights, ask the question in English on [Stack\n| Overflow](https://stackoverflow.com/questions/tagged/pagespeed-insights). For general questions, feedback, and discussion, start a thread in the [mailing list](https://groups.google.com/forum/#!forum/pagespeed-insights-discuss)."]]